var mySwiper = new Swiper('.swiper', {
  direction: 'horizontal', // 垂直切换选项
  loop: true, // 循环模式选项
  effect: 'cube',//设置切换效果
  // 如果需要分页器
  pagination: {
    el: '.swiper-pagination',
  },

  // 如果需要前进后退按钮
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
  // autoplay: {
  //     delay: 1500,
  //     stopOnLastSlide: false,
  //     disableOnInteraction: true,
  //     },
  // 如果需要滚动条
  // scrollbar: {
  //   el: '.swiper-scrollbar',
  // },
})

import { _ajaxTool } from "../utils/_ajax.js";
let haha = document.querySelectorAll(".haha")
// console.log(haha)
// getImg().then(res => {
window.onload = async () => {
  let carousel_box = document.querySelector(".carousel_box");

  // 账号密码
  let useInfo = {
    phone: "18529382970",
    password: "123456"
  }
  // 加载登录
  let loginRes = await _ajaxTool("POST", "http://website.bluej.cn/api/admin/login", useInfo);

  // 存token
  console.log(loginRes, loginRes.data.token);
  window.sessionStorage.setItem("x-token", loginRes.data.token);

  // 获取轮播图
  let carouselFormat = {
    carouselGroupId: 635
  }
  let carouselRes = await _ajaxTool("GET", "http://website.bluej.cn/api/carouselGroup/getAllCarouselGroup", carouselFormat);

  let carouselArr = carouselRes.data.rows;
  console.log(carouselArr);


  //   console.log(res.data.rows[0].Carousels);
  // let urls = res.data.rows[0].Carousels
  haha[0].src = carouselArr[0].Carousels[0].url
  haha[1].src = carouselArr[0].Carousels[1].url
  haha[2].src = carouselArr[0].Carousels[2].url
  haha[3].src = carouselArr[0].Carousels[3].url
  haha[4].src = carouselArr[0].Carousels[4].url
  // haha[5].src = carouselArr[0].Carousels[5].url
  // haha[6].src = carouselArr[6].Carousels[6].url
  // haha[7].src = carouselArr[7].Carousels[7].url
  // haha[8].src = carouselArr[8].Carousels[8].url
  // let i = 0
  // haha.forEach(ele => {
  //   ele.src = carouselArr[0].Carousels[i].url
  //   i++
  // })
  // })
}